fn rs_main1(nums: &mut Vec<i32>) -> i32 {
  let len = nums.len();
  if len < 2 {
    return len as i32;
  }
  let mut count = 0;
  for i in 1..len {
    if nums[count] != nums[i] {
      // 优化?处理器在处理相同数据赋值时是否会直接跳过不执行?
      // if i > count {
      //   nums[count + 1] = nums[i];
      // }
      nums[count + 1] = nums[i];
      count += 1;
    }
  }
  return (count + 1) as i32;
}

fn main() {
  let mut test1: Vec<i32> = vec![1, 1, 2];
  let len1 = rs_main1(&mut test1) as usize;
  test1.truncate(len1);
  println!("{}: {:?}", len1, test1);
  let mut test2: Vec<i32> = vec![1, 2, 2];
  let len2 = rs_main1(&mut test2) as usize;
  test2.truncate(len2);
  println!("{}: {:?}", len2, test2);
}
